Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set helpers #isEqual, adds some test coverage #186

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mrflip
Copy link
Contributor

@mrflip mrflip commented Aug 5, 2022

Addresses #172

Implementation is that two sets are isEqual if they are the same object, or have the same size and B has every element of A.

I did this by duplicating the entire isSubset method and changing the relevant line, rather than first testing for size equality and then delegating to isSubset -- saving operations at the cost of code complexity.

Also have added some test coverage in there. They are largely documentary in that they cover edge cases unlikely to crop up in the current implementation, but which a naïve outsider might like reassurance about (eg that intersecting with an empty set makes an empty set, etc)

Once I've addressed your comments, I can do the same to everything else with isSubset and for other tests.

Copy link
Owner

@Yomguithereal Yomguithereal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mrflip, just a few nitpicks but overall looks good to me.

CHANGELOG.md Outdated
@@ -1,5 +1,9 @@
# Changelog

## 0.39.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 0.40.0 since we are adding a feature. I also usually add (provisional) at the right so that people know until the version is actually released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/set.js Outdated
@@ -11,23 +11,93 @@ describe('Set functions', function() {
describe('#.intersection', function() {

it('should properly compute the intersection of two sets.', function() {
var A = new Set([1, 2, 3]),
B = new Set([2, 3, 4]);
var Exemplar = new Set([2, 3, 1]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those variables should not be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated all, including the pre-existing ones, to all be lowerCameled and more than one character

test/set.js Outdated
var Disjoint = new Set([7, 8, 9]);
var Empty = new Set([])
//
var WithItself = functions.intersection(Exemplar, Exemplar);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test/set.js Outdated

var I = functions.intersection(A, B);
it('Makes no guarantees for element ordering.', function() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the capitalized M :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. In an act of overkill, because the jest eslinter enforces lowercase titles, I added the mocha linter to package.json. It does not; but it did catch some cases where there were arrow functions, which mocha doesn't like. I can remove or file that commit under its own PR if you prefer.

@mrflip mrflip force-pushed the SetIsEqual branch 2 times, most recently from 638fbe1 to 5543bde Compare August 8, 2022 23:01
@mrflip
Copy link
Contributor Author

mrflip commented Aug 8, 2022

I believe I've caught all the test style violations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants